<%@ page language="java"
         import="com.ruohi.manage.DBType,com.ruohi.manage.PoolManager,com.ruohi.manage.Tools,com.ruohi.util.common.CommonForm,com.ruohi.util.common.CommonString"
         pageEncoding="UTF-8" %>
<%@ page import="com.ruohi.util.common.Env" %>
<%@ page import="com.ruohi.util.dbutil.DBHelper" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.TreeMap" %>
<%
	String resDomain = Env.getInstance().getProperty("img_domain");
	Connection connection = null;
	DBHelper dbHelper = DBHelper.getInstance();
	Map model = new HashMap();
	Map categorys = new TreeMap();
	String tableName = "gift_store_category";
	String channelUUID = CommonString.getFormatPara(request.getParameter("channel_uuid"));
	Map adminInfo = (Map)session.getAttribute("adminInfo");
	try{
		connection = PoolManager.getConnection(DBType.getDBTypeByEnum("106013"));
		String id = CommonString.getFormatPara(request.getParameter("id"));
		if(null!=id&&!"".equals(id)){
			model = dbHelper.getMap(" select * from "+tableName+" where uuid = ? ",new Object [] {id} , connection);
		}
		if("".equals(channelUUID)&&null!=model){
			channelUUID = (String)model.get("channel_uuid");
		}
		String sql="select * from gift_store_category ";
		List<Map> categoryList =dbHelper.getMapList(sql,connection);
		String no = "";
		String name = "";
		categorys.put("0","顶级类别");
		if(categoryList != null){
			for(Map m : categoryList){
				no = (String)m.get("no");
				name = (String)m.get("name");
				name = CommonForm.getHtmlSpaceByString((String)m.get("parent_no"))+name;
				categorys.put(no,name);
			}
		}
		no = CommonString.getFormatPara(model.get("no"));
		if("".equals(no)){
			no = Tools.getNo("0",tableName,"106013");
		}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<title><%=Env.getInstance().getProperty("project_name") %></title>
	<link rel="stylesheet" type="text/css" href="/plugin/other/highslide/highslide.css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" charset="utf-8" src="/plugin/editor/ueditor/editor_config.js"></script>
	<script type="text/javascript" charset="utf-8" src="/plugin/editor/ueditor/editor_all_min.js"></script>
	<link rel="stylesheet" type="text/css" href="/plugin/editor/ueditor/themes/default/ueditor.css"/>
	</head>

	<body style="margin: 0;padding: 0;">
    <form name="theform" id="theform" action="/backend/action/crud.jsp?enumNo=106013">
      <div class="formDiv">
        <div class="group"> <span><img src="/plugin/ui/ligerUI/ligerUI/skins/icons/communication.gif" /></span> <span class="groupTitle">基础信息</span> </div>
        <div class="formLeft"><span style="color:#F00">* </span>所属类别</div>
        <div class="formRight" style="width:190px"><select class="jr_select" name="zd_parent_no" id="zd_parent_no" style=" *margin-left:5px"><%=CommonForm.createSelect(categorys,CommonString.getFormatPara(model.get("parent_no"))) %></select></div>
        <div class="formLeft"><span style="color:#F00">* </span>类别编号(自动)</div>
        <div class="formRight" style="width:190px">
          <input type="text" name="zd_no" class="jr_text" id="zd_no" value="<%=no %>"/>
        </div>
        <div style="clear: left;"></div>
        <div class="formLeft"><span style="color:#F00">* </span>类别名称</div>
        <div class="formRight">
          <input type="text" dataType="Require" msg="请输入类别名称" class="jr_text" name="zd_name" id="zd_name" value="<%=CommonString.getFormatPara(model.get("name")) %>" maxlength="50"/>
        </div>
        <div style="clear:left;"></div>
        <div class="formLeft">类别介绍</div>
        <div class="formRight" style="height:270px">
            <script type="text/plain" id="editor_content" style="width:500px; height:200px;"><%=CommonString.getFormatPara(model.get("intro")) %></script>
      		<input type="hidden" name="zd_intro" id="zd_intro" dataType='Limit' min="0" max="2000" msg='类别介绍不能超过2000字' />
        </div>
		<div style="clear:left;"></div>
        <div class="group"> <span><img src="/plugin/ui/ligerUI/ligerUI/skins/icons/communication.gif" /></span> <span class="groupTitle">扩展信息</span> </div>
        <div class="formLeft">是否显示</div>
        <div class="formRight"> <%=CommonForm.createIsRadio(CommonString.getFormatPara(model.get("is_show")),"zd_is_show") %> </div>
        </div>
        <div style="clear:left;"></div>
        <div class="formLeft">点击次数</div>
        <div class="formRight" style="width:200px">
          <input type="text" class="jr_text" name="zd_view_count" id="zd_view_count" value="<%=CommonString.getFormatPara(model.get("view_count")).equals("")?"0":CommonString.getFormatPara(model.get("view_count")) %>" require="false" dataType="Integer" msg="点击次数请输入整数" maxlength="11" />
        </div>
    
	<div style="clear:left;"></div>
    <div class="formLeft">广告1</div>
    <div class="formRight" style="width: 350px; text-align:left;">
      <input type="text" style="width:350px;" readonly="true"  msg='左侧产品图片不能为空！' class="jr_text" name="zd_ad_img1" id="zd_ad_img1" value="<%=CommonString.getFormatPara(model.get("ad_img1")) %>" />
    </div>
    <div class="formRight" style="width: 30px; text-align:left;">
    	<a href="<%=CommonString.getFormatPara(model.get("ad_img1")) %>" id="a_img1" onclick='return hs.expand(this);'><img src="/backend/images/yulan.gif" /></a>
    </div>
    <div class="formRight" style="width: 50px; text-align:left;">
    	<span id="ad_img1" style="float:right;"></span>
    </div>
    <div class="formRight" style="width: 50px; text-align:left;">
    	<span id="img_upload_msg1" style="float:right; display:none; color:red;">上传成功</span>
    </div>
	
	<div style="clear: left;"></div>
        <div class="formLeft">广告1链接</div>
        <div class="formRight">
          <input type="text" class="jr_text" name="zd_ad1_url" id="zd_ad1_url" value="<%=CommonString.getFormatPara(model.get("ad1_url")) %>" maxlength="50"/>
    </div>
	
    <div style="clear:left;"></div>
	
	<div class="formLeft">广告2</div>
    <div class="formRight" style="width: 350px; text-align:left;">
      <input type="text" style="width:350px;" readonly="true"  msg='左侧产品图片不能为空！' class="jr_text" name="zd_ad_img2" id="zd_ad_img2" value="<%=CommonString.getFormatPara(model.get("ad_img2")) %>" />
    </div>
    <div class="formRight" style="width: 30px; text-align:left;">
    	<a href="<%=CommonString.getFormatPara(model.get("ad_img2")) %>" id="a_img2" onclick='return hs.expand(this);'><img src="/backend/images/yulan.gif" /></a>
    </div>
    <div class="formRight" style="width: 50px; text-align:left;">
    	<span id="ad_img2" style="float:right;"></span>
    </div>
    <div class="formRight" style="width: 50px; text-align:left;">
    	<span id="img_upload_msg2" style="float:right; display:none; color:red;">上传成功</span>
    </div>
		<div style="clear: left;"></div>
        <div class="formLeft">广告2链接</div>
        <div class="formRight">
          <input type="text" class="jr_text" name="zd_ad2_url" id="zd_ad2_url" value="<%=CommonString.getFormatPara(model.get("ad2_url")) %>" maxlength="50"/>
    </div>
	
      <input type="hidden" name="zd_order_no" id="zd_order_no" value="<%=CommonString.getFormatPara(model.get("order_no")) %>" />
      <input type="hidden" name="tableName" id="tableName" value="<%=tableName %>" />
      <input type="hidden" name="zd_id" id="zd_id" value="<%=CommonString.getFormatPara(model.get("id")) %>" />
      <input type="hidden" name="zd_channel_uuid" id="zd_channel_uuid" value="<%=channelUUID %>" />
      <input type="hidden" name="eventAfter" id="eventAfter" value="updAppCategoryGift" />
    </form>
</body>
</html>
<script type="text/javascript" src="/plugin/jquery/jquery.form.js"></script>
<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="/backend/scripts/common.js?tab" type="text/javascript"></script>
<script src="/plugin/validator/wofoshan/validator.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/plugin/other/highslide/highslide.min.js"></script>
            <script type="text/javascript" src="http://img.52sdskj.com/plugin/upload/jr_upload.js"></script>
<script type="text/javascript">
	hs.graphicsDir = '/plugin/other/highslide/graphics/';
	hs.wrapperClassName = 'wide-border';
	jQuery("#equi_img").JrUpload({
        remotUrl: "http://img.52sdskj.com/upload.jsp",
		folder : "main" ,
		watermark:false,
		callback : "setEquiImg"
	});
	function doSub(){
		var rs = Validator.Validate(document.getElementById("theform"),1);
		if(rs){
			jQuery("#theform").ajaxSubmit({
					type : "POST",
					async : false ,
					success : function(data) {
						var rs = parseInt(jQuery.trim(data), 10);
						if (rs > 0) {
							jrSuccess("保存成功！");
							<%
							if("".equals(id)){
								%>
							window.location.reload();
								<%
							}
							%>
						} 
					}
				});
		}
	}
	
	var ue_content = new baidu.editor.ui.Editor({
    	textarea : 'zd_intro',
    	autoHeightEnabled:false,
    	watermark : false,
    	minFrameHeight:200
    });
    ue_content.render('editor_content');
    ue_content.addListener("selectionchange",function(){
	    var state_content = ue_content.queryCommandState("source");
	    document.getElementById("zd_intro").value=ue_content.getContent();
	});
	document.getElementById("zd_intro").value=ue_content.getContent();

	jQuery(function(){
		jQuery("#zd_parent_no").change(function(){
			jQuery.post("/backend/action/ajax_r.jsp",{'tableName':'<%=tableName%>','flag':'get_no','pno':this.value,'enumNo':'106013'},function(data){
				jQuery("#zd_no").val(jQuery.trim(data));
			});
		});
	});

	function smallToBig(o,id){
		jQuery(o).attr("href",jQuery("#"+id).val());
		return hs.expand(o);
	}
	
	
	//上传广告1
	$(function(){
		hs.graphicsDir = '/plugin/other/highslide/graphics/';
		hs.wrapperClassName = 'wide-border';
		
		jQuery("#ad_img1").JrUpload({
            remotUrl: "http://img.52sdskj.com/upload.jsp",
			folder : "saygou" ,
			watermark:false,
			multi:false,
			isResize:false,
			callback : "setLeftProductImg1"
		});
	});
		
		function setLeftProductImg1(data){
		if(data != ""){
			$("#zd_ad_img1").val("<%=resDomain %>" + data);
			jQuery("#a_img").attr("href","<%=resDomain %>" + data);
			$("#img_upload_msg1").show();
			$("#img_upload_msg1").delay(3000).hide(0);
		}
	}

	
	//上传广告2
	$(function(){
		hs.graphicsDir = '/plugin/other/highslide/graphics/';
		hs.wrapperClassName = 'wide-border';
		
		jQuery("#ad_img2").JrUpload({
            remotUrl: "http://img.52sdskj.com/upload.jsp",
			folder : "saygou" ,
			watermark:false,
			multi:false,
			isResize:false,
			callback : "setLeftProductImg2"
		});
	});
	function setLeftProductImg2(data){
		if(data != ""){
			$("#zd_ad_img2").val("<%=resDomain %>" + data);
			jQuery("#a_img").attr("href","<%=resDomain %>" + data);
			$("#img_upload_msg2").show();
			$("#img_upload_msg2").delay(3000).hide(0);
		}
	}
	

</script>
<%
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		dbHelper.freeConnection(connection);
	}
%>